#!/bin/bash

>web_pc.txt
>mysql_pc.txt
for i in {1..254}
do

        (nc -z 192.168.0.${i} 80 &>/dev/null
        if (($?==0))
        then
                echo "192.168.0.${i}" >>web_pc.txt
                #echo -e "\e[32m192.168.0.${i} is up \e[0m"
        fi
	nc -z 192.168.0.${i} 3306 &>/dev/null
	if (($?==0))
	then
                echo "192.168.0.${i}" >>mysql_pc.txt

        fi)&
done
sleep 2
b=`cat mysql_pc.txt|wc -l`
a=`cat web_pc.txt|wc -l`
echo -e "\033[34m开启web服务个数:$a \033[0m"
echo -e "\033[31m开启mysql个数:$b \033[0m"
